home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap15 / dun15_7.txt < prev    next >
Encoding:
Text File  |  1997-12-18  |  1.4 KB  |  56 lines

  1. <HTML>
  2.  
  3. <HEAD>
  4.  
  5.   <TITLE>Navigating Page Elements in IE4</TITLE>
  6.  
  7. </HEAD>
  8.  
  9.  
  10.  
  11. <BODY BGCOLOR=white>
  12.  
  13.  
  14.  
  15. <P>
  16.  
  17.   <IMG ID=arrow SRC="arrow.gif" ALIGN=left">
  18.  
  19.   <FONT FACE="Arial, Helvetica" SIZE=+2>
  20.  
  21.      Navigating Page Elements in IE4
  22.  
  23.   </FONT>
  24.  
  25. </P>
  26.  
  27.  
  28.  
  29. <P>The following is the document structure of this web page:
  30.  
  31.  
  32.  
  33.   <BLOCKQUOTE>
  34.  
  35.   <PRE><SCRIPT>
  36.  
  37.     function enumerateChildElements(pageElement)
  38.  
  39.     {
  40.  
  41.       var i = pageElement.sourceIndex + 1;
  42.  
  43.  
  44.  
  45.       // Display the root element
  46.  
  47.       document.writeln(pageElement.tagName);
  48.  
  49.  
  50.  
  51.       // Display elements sequentially while they
  52.  
  53.       // are still contained by pageElement.
  54.  
  55.       //
  56.  
  57.       while (i < document.all.length &&
  58.  
  59.              pageElement.contains(document.all[i]))
  60.  
  61.       {
  62.  
  63.         // Indent the element three spaces for each
  64.  
  65.         // parent between the current element and
  66.  
  67.         // root element
  68.  
  69.         //
  70.  
  71.         parentElement = document.all[i].parentElement;
  72.  
  73.         while (parentElement != pageElement && parentElement != null)
  74.  
  75.         {
  76.  
  77.           parentElement = parentElement.parentElement;
  78.  
  79.           document.write("   ");
  80.  
  81.         }
  82.  
  83.  
  84.  
  85.         // Display the tag name and move to the next element
  86.  
  87.         document.writeln("   " + document.all[i].tagName);
  88.  
  89.         i++;
  90.  
  91.       }
  92.  
  93.     }
  94.  
  95.  
  96.  
  97.     enumerateChildElements(document.all[0]);
  98.  
  99.   </SCRIPT></PRE>
  100.  
  101.   </BLOCKQUOTE>
  102.  
  103. </P>
  104.  
  105.  
  106.  
  107. </BODY>
  108.  
  109. </HTML>
  110.  
  111.